Editing User:Gaganjyotsingh/Proposal/LibreCADkickoff
From BRL-CAD
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 49: | Line 49: | ||
For the Line, the move can be implemented as | For the Line, the move can be implemented as | ||
− | |||
void move_line ( coordinate offset ) { | void move_line ( coordinate offset ) { | ||
− | |||
start_point = start_point + offset; | start_point = start_point + offset; | ||
− | |||
end_point = end_point + offset; | end_point = end_point + offset; | ||
− | |||
} | } | ||
delete_line(id); // Immutable approach, older gets deleted and a new will be created. | delete_line(id); // Immutable approach, older gets deleted and a new will be created. | ||
− | |||
new_line(start_point, end_point); // values changed above. | new_line(start_point, end_point); // values changed above. | ||
− | |||
For Circle and Arc, the center will be moved by the offset value | For Circle and Arc, the center will be moved by the offset value | ||
Line 86: | Line 80: | ||
void rotate ( double angle ) { | void rotate ( double angle ) { | ||
− | |||
// Rotation around itself at some angle. | // Rotation around itself at some angle. | ||
− | + | // first the double value will be converted into a coordinate using sin cos functions for x and y coordinate respectively | |
− | // first the double value will be converted into a coordinate using sin cos | ||
− | functions for x and y coordinate respectively | ||
and then the algo will be applied to rotate the entity. Which is like | and then the algo will be applied to rotate the entity. Which is like | ||
− | |||
temp_x = x * angle.x – y * angle.y // stored in temp since we need older x value | temp_x = x * angle.x – y * angle.y // stored in temp since we need older x value | ||
− | |||
y = x * angle.y – y * angle.x | y = x * angle.y – y * angle.x | ||
− | |||
x = temp | x = temp | ||
− | |||
} | } | ||
Line 109: | Line 96: | ||
*Text will have support for the following attributes, | *Text will have support for the following attributes, | ||
− | + | Insertion point : The point at wich entity is to be inserted. | |
− | + | SecondPoint : It is used by the aligned fit. | |
− | + | Widthrel : It is the width of reference rectangle around the text. | |
− | + | Height : Height of text | |
− | + | Valign : Vertical Alignment of the Dimension value text | |
− | + | Halign : Horizontal Alignment of the dimension value text | |
− | + | Text : Text value held by dimension entity | |
− | + | Style : Style of the text | |
− | + | Angle : If the text is aligned at some angle | |
*Dimension has the following attributes, | *Dimension has the following attributes, | ||
− | + | DefinitionPoint : The point at which dimension is defined | |
− | + | MiddleOfText : Middle of the dimension text | |
− | + | Valign : Vertical Alignment of the Dimension value text | |
− | + | Halign : Horizontal Alignment of the dimension value text | |
− | + | LineSpacingStyle : Spacing style if any for the dimension | |
− | + | LineSpacingFactor : Spacing factor if any | |
− | + | Text : Text value held by dimension entity | |
− | + | Style : Style of the text | |
− | + | Angle : If the text is aligned at some angle | |
====Intersection Stuff==== | ====Intersection Stuff==== | ||
Line 135: | Line 122: | ||
The Kernel manages the intersection of two entities. The types of entities being Arc, Line, Ellipse, circle, point if we create the functions to check and return intersection between entities, we will get a number of functions. | The Kernel manages the intersection of two entities. The types of entities being Arc, Line, Ellipse, circle, point if we create the functions to check and return intersection between entities, we will get a number of functions. | ||
For example : | For example : | ||
− | |||
intersect_line_line(line, line); | intersect_line_line(line, line); | ||
− | |||
intersect_line_arc(line, arc); | intersect_line_arc(line, arc); | ||
− | |||
intersect_line_ellipse(line, ellipse); | intersect_line_ellipse(line, ellipse); | ||
− | |||
and so on for every entity. | and so on for every entity. | ||
Line 147: | Line 130: | ||
quad1 = line.get_quadratic() | quad1 = line.get_quadratic() | ||
− | |||
quad2 = circle.get_quadratic() | quad2 = circle.get_quadratic() | ||
− | |||
quad3 = ellipse.get_quadratic() // ellipse quadratic equation | quad3 = ellipse.get_quadratic() // ellipse quadratic equation | ||
− | |||
get_intersection(quad1,quad2) // will give intersection points of line and circle | get_intersection(quad1,quad2) // will give intersection points of line and circle | ||
− | |||
get_intersection(quad1,quad3)// will give intersection points of line and ellipse | get_intersection(quad1,quad3)// will give intersection points of line and ellipse | ||
Line 159: | Line 138: | ||
Approach 1 ( Line Line direct intersection calculation ) | Approach 1 ( Line Line direct intersection calculation ) | ||
− | |||
void Intersect::visit(shared_ptr<const lc::Line> l1, shared_ptr<const lc::Line> l2) { | void Intersect::visit(shared_ptr<const lc::Line> l1, shared_ptr<const lc::Line> l2) { | ||
Line 197: | Line 175: | ||
References : | References : | ||
http://en.wikipedia.org/wiki/Quadratic_form | http://en.wikipedia.org/wiki/Quadratic_form | ||
− | |||
Maths will be taken from LibreCAD2 : | Maths will be taken from LibreCAD2 : | ||
− | |||
https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/math/lc_quadratic.h | https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/math/lc_quadratic.h | ||
− | |||
https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/math/rs_math.h | https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/math/rs_math.h | ||